extends TileMapLayer


const GRASS = preload("res://entities/item/树.tscn")
@export var create: PackedScene

const OFFSET = 10
@export var spawn_root: Node



func _ready() -> void:
	enabled = false

	if is_multiplayer_authority():
		var cellArray = get_used_cells()
		
		for cellCoordinate in cellArray:
			var newGrass = GRASS.instantiate()
			newGrass.global_position = global_position + Vector2(cellCoordinate * 32.0) + Vector2(16,16)
			
			spawn_root.add_child.call_deferred(newGrass, true)
			
			#var randomOffset = Vector2(randf_range(-OFFSET,OFFSET),randf_range(-OFFSET,OFFSET))
			#newGrass.global_position += randomOffset 
			
			newGrass.get_node("Sprite2D").flip_h = randi_range(0,1)
		
		
		
	
	
	
	
